﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace library
{
    public partial class change_do : Form
    {
        public MySqlConnection conn = new DBclass().getConn();
        string Rname, Mag;
        public change_do(string rname,string mag)
        {
            this.Rname = rname;
            this.Mag = mag;

            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            conn.Open();
            string sql = "update fine_rule set mag=@mag where rname=@rname";
            MySqlCommand cmd = new MySqlCommand(sql, conn);
            cmd.Parameters.Add("@mag", MySqlDbType.Double).Value = textBox2.Text;
            cmd.Parameters.Add("@rname", MySqlDbType.VarChar, 50).Value = textBox1.Text;
            int res = cmd.ExecuteNonQuery();
            if (res > 0)
                MessageBox.Show("修改成功！");
            else
            {
                MessageBox.Show("修改失败！");
            }
            conn.Close();
        }

        private void change_do_Load(object sender, EventArgs e)
        {
            textBox1.Text = Rname;
            textBox2.Text = Mag;
        }
    }
}
